<!-- 用户管理 -->
<template>
  <div class="app-container">
    <div class="home-img">
      <img src="../../../assets/images/h01.png" alt="" />
    </div>
    <div class="home-blue-text">
      您好，我是"桥医生"，精通各式桥型的"疑难杂症"。
    </div>
    <div class="home-white-text">
      首先，我们先从下面不同专家中选择需要咨询的桥型吧!
    </div>
    <div class="home-content">
      <el-card
        shadow="never"
        class="small-card"
        v-for="(item, index) in menuList"
        :key="index"
        @click="changeBridge(item.code)"
      >
        <img :src="item.img" alt="" />
        <div class="home-card-text">{{ item.name }}</div>
      </el-card>
    </div>
  </div>
</template>

<script setup lang="ts">
import router from "@/router";
import { useBridgeStore } from "@/store";
import { listBridge } from "@/api/ai/bridge/index";

defineOptions({
  name: "Home",
  inheritAttrs: false,
});
const menuList = ref<any[]>([]);

const bridgeStore = useBridgeStore();

function changeBridge(type: string) {
  bridgeStore.changeType(type);
  router.push("/bridge/disease");
}

// 获取桥型
function getBridge() {
  listBridge().then(({ data }) => {
    data.forEach((item, index) => {
      item.img = new URL(
        `../../../assets/images/h0${index + 2}.png`,
        import.meta.url
      ).href;
    });
    menuList.value = data;
  });
}

onMounted(() => {
  getBridge();
});
</script>

<style lang="scss" scoped>
.home-img {
  width: 482px;
  height: 108px;
  margin: 0 auto;

  img {
    width: 85%;
    height: 85%;
  }
}

.home-blue-text {
  font-weight: 300;
  font-size: 18px;
  color: #5effff;
  line-height: 21px;
  text-align: center;
  margin: 15px 0 11px 0;
}

.home-white-text {
  font-weight: 300;
  font-size: 14px;
  color: $main-text;
  text-align: center;
  line-height: 16px;
  margin-bottom: 38px;
}

.home-content {
  width: 54%;
  margin: 0 auto;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;

  .small-card {
    width: 32%;
    height: 184px;
    text-align: center;
    margin-right: 2%;
    margin-bottom: 15px;

    &:nth-child(3n) {
      margin-right: 0;
    }

    &:last-child {
      margin-right: 0;
    }

    &:hover {
      border-color: rgb(247, 100, 100);
    }

    img {
      width: 104px;
      height: 104px;
      margin: 19px 0 15px;
    }

    .home-card-text {
      font-size: 22px;
      color: $main-text;
      line-height: 26px;
      text-align: center;
    }
  }
}
</style>
